package com.guli.gulimall.product.web.controller;

import com.guli.gulimall.product.entity.CategoryEntity;
import com.guli.gulimall.product.service.CategoryService;
import com.guli.gulimall.product.vo.Catelog2Vo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

/**
 * @Author XushaoQing
 * @Date:2022/6/17 16:38
 * @Description:
 */
@Controller
public class IndexController {

    @Autowired
    CategoryService categoryService;

    @RequestMapping(value = {"/","/index"})
    public String index(Model model){
        //查询所有的1级分类

       List<CategoryEntity> l1List = categoryService.l1List();

    model.addAttribute("list",l1List);



        return "index";
    }

    @RequestMapping("/getCatelog2List")
    @ResponseBody
    public Map<Long,List<Catelog2Vo>> getCatelog2List(){


        return categoryService.getCatelog2List();
    }
}
